package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IHousekeepingFeeTypeServiceDao;
import com.java110.dto.housekeeping.HousekeepingFeeTypeDto;
import com.java110.dto.housekeeping.HousekeepingServFeeDto;
import com.java110.intf.cart.IHousekeepingFeeTypeInnerServiceSMO;
import com.java110.po.housekeeping.HousekeepingFeeTypePo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 费用类型内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingFeeTypeInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingFeeTypeInnerServiceSMO {

    @Autowired
    private IHousekeepingFeeTypeServiceDao housekeepingFeeTypeServiceDaoImpl;


    @Override
    public int saveHousekeepingFeeType(@RequestBody HousekeepingFeeTypePo housekeepingFeeTypePo) {
        int saveFlag = 1;
        housekeepingFeeTypeServiceDaoImpl.saveHousekeepingFeeTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeTypePo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingFeeType(@RequestBody  HousekeepingFeeTypePo housekeepingFeeTypePo) {
        int saveFlag = 1;
         housekeepingFeeTypeServiceDaoImpl.updateHousekeepingFeeTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeTypePo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingFeeType(@RequestBody  HousekeepingFeeTypePo housekeepingFeeTypePo) {
        int saveFlag = 1;
        housekeepingFeeTypePo.setStatusCd("1");
        housekeepingFeeTypeServiceDaoImpl.updateHousekeepingFeeTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeTypePo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingFeeTypeDto> queryHousekeepingFeeTypes(@RequestBody  HousekeepingFeeTypeDto housekeepingFeeTypeDto) {

        //校验是否传了 分页信息

        int page = housekeepingFeeTypeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingFeeTypeDto.setPage((page - 1) * housekeepingFeeTypeDto.getRow());
        }

        List<HousekeepingFeeTypeDto> housekeepingFeeTypes = BeanConvertUtil.covertBeanList(housekeepingFeeTypeServiceDaoImpl.getHousekeepingFeeTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingFeeTypeDto)), HousekeepingFeeTypeDto.class);

        return housekeepingFeeTypes;
    }

    @Override
    public List<HousekeepingFeeTypeDto> queryHousekeepingServFeeTypes(HousekeepingServFeeDto housekeepingServFeeDto) {
        //校验是否传了 分页信息

        int page = housekeepingServFeeDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServFeeDto.setPage((page - 1) * housekeepingServFeeDto.getRow());
        }

        List<HousekeepingFeeTypeDto> housekeepingFeeTypes = BeanConvertUtil.covertBeanList(housekeepingFeeTypeServiceDaoImpl.getHousekeepingServFeeTypeInfo(BeanConvertUtil.beanCovertMap(housekeepingServFeeDto)), HousekeepingFeeTypeDto.class);

        return housekeepingFeeTypes;
    }


    @Override
    public int queryHousekeepingFeeTypesCount(@RequestBody HousekeepingFeeTypeDto housekeepingFeeTypeDto) {
        return housekeepingFeeTypeServiceDaoImpl.queryHousekeepingFeeTypesCount(BeanConvertUtil.beanCovertMap(housekeepingFeeTypeDto));    }

    public IHousekeepingFeeTypeServiceDao getHousekeepingFeeTypeServiceDaoImpl() {
        return housekeepingFeeTypeServiceDaoImpl;
    }

    public void setHousekeepingFeeTypeServiceDaoImpl(IHousekeepingFeeTypeServiceDao housekeepingFeeTypeServiceDaoImpl) {
        this.housekeepingFeeTypeServiceDaoImpl = housekeepingFeeTypeServiceDaoImpl;
    }
}
